package com.zsxj.xixi.controller;

import com.zsxj.xixi.common.Result;
import com.zsxj.xixi.common.validation.Phone;
import com.zsxj.xixi.service.tag.TagService;
import com.zsxj.xixi.service.tag.TagVO;
import com.zsxj.xixi.service.tag.queryParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static com.zsxj.xixi.common.Result.ok;

/**
 * @Description
 * @Author mengweibin
 * @Date 2021-07-07 10:56
 */
@Api(tags = {"小标签 控制器"})
@RestController
@Slf4j
public class TagController {

    @Resource
    private TagService tagService;


    @ApiOperation(value = "通过货品名称查询小标签", notes = "通过货品名称模糊搜索小标签条形码")
    @PostMapping("/query/tag")
    public Result<List<TagVO>> queryTagsByGoodsName(@RequestParam String spuName) {
        return ok(tagService.queryTagsByGoodsName(spuName));
    }

    @PostMapping("/test/validate")
    public Result testFun1(@RequestBody @Validated queryParam param) {
        log.info("入参param ==> {}", param);
        return ok();
    }

    @PostMapping("/create/info")
    public Result createInfo(@RequestBody @Valid queryParam param) {
        log.info("创建成功。。。。 param=>{}", param);
        return ok("创建成功");
    }

    @PutMapping("/update/info")
    public Result updateInfo(@RequestBody @Valid queryParam param) {
        log.info("修改成功，，， param=>{}", param);
        return ok("修改成功");
    }
}
